package com.example.demo_1106.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.demo_1106.entity.GoodsKind;
import com.example.demo_1106.service.GoodsKindService;
import com.example.demo_1106.mapper.GoodsKindMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author kongke
 * @description 针对表【goods_kind】的数据库操作Service实现
 * @createDate 2023-07-23 10:09:06
 */
@Service
public class GoodsKindServiceImpl extends ServiceImpl<GoodsKindMapper, GoodsKind>
        implements GoodsKindService {

    @Autowired
    GoodsKindMapper goodsKindMapper;

    @Override
    public boolean delGoodkind(String kindcode) {
        int del = goodsKindMapper.delete(new QueryWrapper<GoodsKind>().eq("kind_code", kindcode));
        return del != 0;
    }

    @Override
    public List<GoodsKind> getGoodsKind(String kindcode) {
        List<GoodsKind> goodsKindList;
        if ("".equals(kindcode) || kindcode == null) {
            goodsKindList = goodsKindMapper.selectList(null);
        } else {
            goodsKindList = goodsKindMapper.selectList(new QueryWrapper<GoodsKind>().eq("kind_code", kindcode));
        }
        return goodsKindList;
    }
}




